package pl.net.csrv.beans;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

/**
 * @author Maciek
 * 
 */
@Entity
@Table(name = "Service")
public class Service {

	/**
	 * User
	 */
	@Id
	@Column(name = "ID")
	Long id;

	@OneToOne(cascade={CascadeType.ALL})
	@JoinColumn(name="USER_ID")
	private User user;

	/**
	 * Tools
	 */
	@Transient
	private List<Tool> tool;

	/**
	 * Mechanic
	 */
	@OneToOne(cascade={CascadeType.ALL})
	@JoinColumn(name="MECHANIC_ID")
	private Mechanic mechanic;

	/**
	 * Car
	 */
	@OneToOne(cascade={CascadeType.ALL})
	@JoinColumn(name="CAR_ID")
	private Car car;

	/**
	 * creationDate
	 */
	@Temporal(TemporalType.DATE)
	@Column(name="CREATION_DATE")
	private Date creationDate;

	/**
	 * comment
	 */
	@Column(name="S_COMMENT")
	private String comment;

	/**
	 * @return
	 */
	public User getUser() {
		return user;
	}

	/**
	 * @param user
	 */
	public void setUser(User user) {
		this.user = user;
	}

	/**
	 * @return
	 */
	public List<Tool> getTool() {
		if (tool == null) {
			return new ArrayList<Tool>();
		}
		return tool;
	}

	/**
	 * @param tool
	 */
	public void setTool(List<Tool> tool) {
		this.tool = tool;
	}

	/**
	 * @return
	 */
	public Mechanic getMechanic() {
		return mechanic;
	}

	/**
	 * @param mechanic
	 */
	public void setMechanic(Mechanic mechanic) {
		this.mechanic = mechanic;
	}

	/**
	 * @return
	 */
	public Car getCar() {
		return car;
	}

	/**
	 * @param car
	 */
	public void setCar(Car car) {
		this.car = car;
	}

	/**
	 * @return
	 */
	public Date getCreationDate() {
		return creationDate;
	}

	/**
	 * @param creationDate
	 */
	public void setCreationDate(Date creationDate) {
		this.creationDate = creationDate;
	}

	/**
	 * @return
	 */
	public Long getId() {
		return id;
	}

	/**
	 * @param id
	 */
	public void setId(Long id) {
		this.id = id;
	}

	/**
	 * @return
	 */
	public String getComment() {
		return comment;
	}

	/**
	 * @param comment
	 */
	public void setComment(String comment) {
		this.comment = comment;
	}
}
